package com.candy.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
@WebListener
public class SessionListener implements HttpSessionListener , HttpSessionAttributeListener {
    @Override
    public void attributeAdded(HttpSessionBindingEvent event) {
        System.out.println("已监听到session作用域中数据新增，"+event.getName()+";"+event.getValue());
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent event) {
        System.out.println("已监听到session作用域中数据移除，"+event.getName()+";"+event.getValue());
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent event) {
        System.out.println("已监听到session作用域中数据更新，"+event.getName()+";"+event.getValue());
    }

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        System.out.println("Session对象的创建");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println("Session对象的销毁");
    }
}
